home *** CD-ROM | disk | FTP | other *** search
- Path: news-m01.ny.us.ibm.net!usenet
- From: mshan@ibm.net (Mike Shannon)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: 10 Apr 1996 00:03:15 GMT
- Message-ID: <4kets3$ic0@news-s01.ny.us.ibm.net>
- References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg> <828964950snz@genesis.demon.co.uk> <dewar.828987544@schonberg> <4kbuebINNrho@keats.ugrad.cs.ubc.ca> <dewar.829048603@schonberg>
- Reply-To: mshan@ibm.net (Mike Shannon)
- NNTP-Posting-Host: slip129-37-236-83.tx.us.ibm.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <dewar.829048603@schonberg>, dewar@cs.nyu.edu (Robert Dewar) writes:
-
- >There are two possible semantics that ould
- >be defined for read (buffer must be at least size of the read argument,
- >or buffer must be at least size of data read). Both are easy to specify,
- >both are easy to implement. You cannot rely on common sense
- > ...
-
- I'm a latecomer to this dispute, but this is not smart:
-
- char buf[100];
-
- read(fd,buf,1000);
-
- Common sense, which tells me not to do such things, is a welcome ally.
-
- >We are after all dealing with a language interface where in practice the
- >proper check (whichever it is) cannot be made, because the called routine
- >does not know the length of the buffer passed. I think a natural default
- >assumption, in the absence of any statement to the contrary, is that the
- >bytes are blindly read into the buffer, and disaster strikes if the number
- >of bytes read is greater than the buffer length, but otherwise all is well.
- >Unless there is a VERY clear statement of semantics to the contrary, I
- >don't see how anyone can call code that makes this assumption obviously
- >broken.
-
- SIGSEGV is invited, not by any "statement of semantics", but by careless
- code. If you use these functions without reasonable care, then you
- experience the consequences. If you do this for a living, you learn not
- to waste time on unnecessary chances.
-
- >Specs need to be made precise,
- >so that a caller knows EXACTLY what the requirements are without having
- >to guess, or, worse still, examine the actual implementation code.
-
- Good specs do not write good code - good programmers do.
-
- By the way, how did all this get started?
-
- Mike Shannon
- Houston, Texas
-
- <!> Once we had computers and dumb terminals.
- <!> Now we have computers and stupid terminals.
- <!> Thanks, Microsoft.
-
-